package com.share.gateway.config;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 网关路由配置
 *
 * @author share
 */
@Configuration
public class GatewayRouteConfig {

    @Bean
    public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
        return builder.routes()
                // 认证服务路由
                .route("share-auth", r -> r.path("/auth/**")
                        .uri("lb://share-auth"))
                // 用户服务路由
                .route("share-user", r -> r.path("/user/**")
                        .uri("lb://share-user"))
                // 其他服务路由可以继续添加
                .build();
    }
}